import {
    ycSourceList, ycZtList
} from '/@/views/examination-audit/abnormal-examination-paper/components/index'


function mergeCells(text, data, key, index) {
    console.log(text, data, key, index);

    // 上一行该列数据是否一样
    if (index !== 0 && text === data[index - 1][key]) {
        return 0
    } else {
        let rowSpan = 1
        // 判断下一行是否相等
        for (let i = index + 1; i < data.length; i++) {
            if (text !== data[i][key]) {
                break
            }
            rowSpan++
        }
        return rowSpan
    }
}

let lfYcList: any[] = []
import { getDictionaryList } from '/@/views/teacher/home/index'

async function getLfYyList() {
    lfYcList = await getDictionaryList('lfCode')
}
getLfYyList()


export function columns(infoSet) {
    return [
        {
            title: '题号',
            dataIndex: 'tmbh',
            key: 'tmbh',
            align: 'center',
            customRender: ({ text, record, index }) => {
                return `${text}${record.tmbt || ''}`
                // if (text != '') {
                //     return {
                //         children: text,
                //         // props: {
                //         //     rowSpan: mergeCells(text, infoSet.value?.zgtDetailVOList || [], 'tmbh', index),
                //         // },
                //     }
                // }
            },
        },
        {
            title: '题目满分',
            dataIndex: 'tmfz',
            key: 'tmfz',
            align: 'center',
        },
        {
            title: '得分',
            dataIndex: 'pyZdf',
            key: 'pyZdf',
            align: 'center',
        },
        {
            title: '违规违纪违法',
            dataIndex: 'wgwjwf',
            key: 'wgwjwf',
            align: 'center',
        },
        // {
        //     title: '零分原因',
        //     dataIndex: 'lfCode',
        //     key: 'lfCode',
        //     align: 'center',
        //     customRender: ({ record }) => {
        //         return lfYcList.find((item: any) => item.value == record.lfCode)?.label || ''
        //     },
        // },
        // {
        //     title: '阅卷教师',
        //     dataIndex: 'yjLsMc',
        //     key: 'yjLsMc',
        //     align: 'center',
        //     customRender: ({ text, record }) => {
        //         if (text == null) return '--'
        //         return `(${record.jsgh})${text}`
        //     },
        // },
        // {
        //     title: '操作',
        //     dataIndex: 'cp',
        //     key: 'cp',
        //     align: 'center',
        // },
    ]
}

export function errRolumns() {
    return [{
        title: '序号',
        key: 'index',
        dataIndex: 'index',
        align: 'center',
        fixed: true,
        width: 60,
    },
    {
        title: '异常来源',
        key: 'ycSource',
        dataIndex: 'ycSource',
        align: 'center',
        customRender: ({ text }) => {
            return ycSourceList.value?.find(item => item.value === text)?.label || ''
        },
    },
    {
        title: '异常状态',
        key: 'ycZt',
        dataIndex: 'ycZt',
        align: 'center',
        customRender: ({ text }) => {
            return ycZtList.value?.find(item => item.value === text)?.label || ''
        },
    },
    {
        title: '上报人',
        key: 'createAccount',
        dataIndex: 'createAccount',
        align: 'center',
        customRender: ({ record }) => {
            if (!record.createAccount) return ''
            return `(${record.createName})${record.createAccount}`
        },
    },

    {
        title: '操作',
        key: 'handle',
        align: 'center',
        width: 100,
        fixed: 'right',
    }]
}




export function wgwgwfRolumns() {
    return [{
        title: '序号',
        key: 'index',
        dataIndex: 'index',
        align: 'center',
        fixed: true,
        width: 60,
    },
    {
        title: '题号',
        key: 'tmbh',
        dataIndex: 'tmbh',
        align: 'center',
    }, {
        title: '处理方式',
        key: 'remark',
        dataIndex: 'remark',
        align: 'center',
    },
    {
        title: '上报人',
        key: 'createAccount',
        dataIndex: 'createAccount',
        align: 'center',
        customRender: ({ record }) => {
            if (!record.createAccount) return ''
            return `(${record.createName})${record.createAccount}`
        },
    },

    {
        title: '操作',
        key: 'handle',
        align: 'center',
        width: 100,
        fixed: 'right',
    }]
}